import React, { Fragment } from 'react';
import { Redirect } from 'umi'

const Authorized: React.FC<{
  children: boolean | React.ReactChild | React.ReactFragment | React.ReactPortal | null | undefined
}> = (props) => {
  const isLogin = Math.random() < 0.95;

  if (isLogin) {
    return <Fragment>{props.children}</Fragment>;
  } else {
    return <Redirect to="/login" />;
  }
}

export default Authorized
